package com.ebt.m.policy.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import com.ebt.m.R;
import com.ebt.m.commons.buscomponent.listview.IView;
import com.ebt.m.data.rxModel.apibean.PolicyProposal;

import butterknife.BindView;
import butterknife.ButterKnife;

public class PolicyProposalTitleView extends IView implements View.OnClickListener {

    private Context mContext;
    @BindView(R.id.tv_name)
    TextView tv_name;
    @BindView(R.id.tv_more)
    TextView tv_more;

    PolicyProposal item;

    public PolicyProposalTitleView(Context context) {
        this(context, null);
    }

    public PolicyProposalTitleView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public PolicyProposalTitleView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext = context;
        View contentView = inflate(context, R.layout.view_policy_proposal_title, this);
        ButterKnife.bind(this);
        tv_more.setOnClickListener(this);
    }

    @Override
    public void update(Object... args) {
        item = (PolicyProposal) args[0];
        tv_name.setText(item.name);
        if (item.proposalItems.size() > 3) {
            tv_more.setVisibility(VISIBLE);
        } else {
            tv_more.setVisibility(GONE);
        }
    }

    @Override
    public void onClick(View v) {
        if (mOnclickListner != null) {
            mOnclickListner.onClick(v, item);
        }
    }
}